package com.ruoyi.web.controller.wechatApplet;

import com.ruoyi.background.domain.AppBanner;
import com.ruoyi.background.service.IAppBannerService;
import com.ruoyi.background.utils.SYS_CONSTANT;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * banner controller
 */
@RestController
@RequestMapping("/wechat/banner")
public class BannerController extends BaseController {

    @Autowired
    private IAppBannerService appBannerService;

    @Autowired
    private RedisCache redisCache;

    /**
     * 请求banner列表
     *
     * @param appBanner 请求条件
     * @return 结果
     */
    @GetMapping("/list")
    public TableDataInfo getList(AppBanner appBanner) {
//        String key = REDIS_KEY.BANNER_LIST_KEY;
//        List<AppBanner> bannerList = redisCache.getCacheList(key);
//        if (ObjectUtils.isEmpty(bannerList)) {
//            appBanner.setStatus(0);
//            bannerList = appBannerService.selectAppBannerList(appBanner);
//            redisCache.deleteByKey(key);
//            redisCache.setCacheList(key, bannerList);
//            redisCache.expire(key, 2 * 60, TimeUnit.MINUTES);
//        }
        return getDataTable(SYS_CONSTANT.BANNER_LIST_CONS);

    }
}
